package com.quickboot.system.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.quickboot.common.controller.BaseController;
import com.quickboot.common.entity.Result;
import com.quickboot.common.entity.TableResult;
import com.quickboot.system.service.SysRolePermissionService;
import com.quickboot.system.vo.SysRolePermissionVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 角色权限
 *
 * @author Tellsea
 * @date 2022-12-17
 */
@Api(tags = "角色权限")
@RestController
@RequestMapping("/system/sysRolePermission")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class SysRolePermissionController extends BaseController {

    private final SysRolePermissionService sysRolePermissionService;

    @ApiOperation("查询列表")
    @SaCheckPermission("system:sysRolePermission:list")
    @GetMapping("/list")
    public TableResult<SysRolePermissionVo> queryList(SysRolePermissionVo entity) {
        return TableResult.ok(sysRolePermissionService.queryList(getPage(), entity));
    }

    @ApiOperation("根据ID查询")
    @SaCheckPermission("system:sysRolePermission:get")
    @GetMapping("/queryById/{id}")
    public Result<SysRolePermissionVo> queryById(@PathVariable("id") Long id) {
        return queryResult(sysRolePermissionService.queryById(id));
    }

}
